#include "qerrorbutton.h"

QErrorButton::QErrorButton(QString id,QString icon,QString text,QWidget *parent)
	: QWidget(parent),m_id(id)
{
	ui.setupUi(this);
	connect(ui.button,SIGNAL(clicked()),this,SLOT(state()));
	ui.button->setStyleSheet(QString::fromUtf8("QPushButton {"
		"border-left: 1px solid #6593CF;"
		"border-top: 1px solid #6593CF;"
		"border-right: 1px solid #6593CF;"
		"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
									"stop: 0 #E3EFFF, stop: 0.40 #C7DFFF, stop: 0.41 #AED1FF, stop: 1 #C0DBFF);"
		"min-width: 80px;"
		"image: url(%1);"
		"image-position: left; }"

		"QPushButton:pressed {"
		"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
									"stop: 0 #dadbde, stop: 1 #f6f7fa);}"

		"QPushButton:hover {"
		"border-left: 1px solid #6593CF;"
		"border-top: 1px solid #6593CF;"
		"border-right: 1px solid #6593CF;"
		"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
									"stop: 0 #FFFCDE, stop: 0.42 #FFEAAD, stop: 0.43 #FFD76A, stop: 1 #FFE69E);"
		"min-width: 80px;		}"

		"QPushButton:checked {"
		"border-left: 1px solid #6593CF;"
		"border-top: 1px solid #6593CF;"
		"border-right: 1px solid #6593CF;"
		"background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
									"stop: 0 #FFD6A4, stop: 0.42 #FFBE73, stop: 0.43 #FEAE42, stop: 1 #FEE17A);"
		"min-width: 80px;		}").arg(icon));

		ui.button->setText(text);
}

QErrorButton::~QErrorButton()
{

}


void QErrorButton::state()
{
	if(ui.button->isChecked())
	{
		emit selected(m_id);
	}
}

void QErrorButton::deselect()
{
	ui.button->setChecked(false);
}